<template>
  <div id="app">
    <h1>{{$store.getters.arr}}</h1>
    <ul>
      <li v-for="item in arr" :key="item">{{item}}</li>
    </ul>
    <h1>根组件{{$store.state.count}}</h1>
    <!-- <input @input="change" type="text" :value="$store.state.count"> -->
    <input @input="change" type="text" :value="$store.state.count">

    <add-item></add-item>
    <hr>
    <sub-item></sub-item>
  </div>
</template>

<script>
import AddItem from './components/add-item.vue'
import SubItem from './components/sub-item.vue'
import {mapState,mapGetters} from 'vuex'
import {mapMutations} from 'vuex'


export default {
  name: 'app',
  data: function () {
    return {
      
    }
  },
  components: {
    AddItem,
    SubItem,
  },
  computed:{
    ...mapState(['count']),
    ...mapGetters( ['arr']),
  },
  methods:{
    ...mapMutations(['changeCount']),
    change(e){
      // this.$store.commit('changeCount', +e.target.value)
      this.changeCount(e.target.value)
    }
  }
}
</script>

<style>
#app {
  width: 600px;
  margin: 20px auto;
  border: 3px solid #ccc;
  border-radius: 3px;
  padding: 10px;
}
</style>